package com.quanquan.user.controller;

import com.quanquan.user.dto.DataDTO;
import com.quanquan.user.service.DataService;
import enums.ResCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import web.response.ResultBody;

/**
 * @ClassName:DataController
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/5/9 11:00
 * @Version 1.0
 */
@Controller
@RequestMapping("/data")
public class DataController {

    private final DataService dataService;

    @Autowired
    public DataController(DataService dataService) {
        this.dataService = dataService;
    }

    /**
     * 首页数据统计
     *
     * @return
     */
    @RequestMapping("/all_count")
    @ResponseBody
    public ResultBody allCount(){
        DataDTO dataDTO = dataService.findDatas();
        if (dataDTO==null){
            return new ResultBody(ResCodeEnum.FAIL.getCode(), "FAIL");
        }
        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), "SUCCESS", dataDTO);
    }

}
